import Vue from 'vue'
import App from './App.vue'
import Login from './components/Login.vue'

import Element from 'element-ui'
import VueRouter from 'vue-router'
import router from './route/index'
import components from './components/common/index'
// import VueQuillEditor from 'vue-quill-editor'
import {get} from './utils/request'
import api from './utils/api'

Vue.use(Element)
Vue.use(VueRouter)
// Vue.use(VueQuillEditor)

components.map(component => {
    Vue.component(component.name, component)
})

// Vue.prototype.$axios = axios

/*css*/
import 'element-ui/lib/theme-chalk/index.css'
import './assets/main.css'
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.config.productionTip = false

const init = function () {
    get(api.getLoginStatus,{

    }).then(res=>{
        if(res.code === 702){
            new Vue({
                render: h => h(Login)
            }).$mount('#app')
        }else {
            new Vue({
                router,
                render: h => h(App)
            }).$mount('#app')
        }
    }).catch(err=>{
        new Vue({
            render: h => h(Login)
        }).$mount('#app')
    })
}
init()

// myapp.$router.beforeEach((to,from,next)=>{
//     console.log(to)
//     console.log(to.query)
//     next()
// })
// console.log(myapp.$route,Vue.route)
